import java.util.Arrays;

public class Solution {
    public int findContentChildren(int[] g, int[] s) {
        int lenG = g.length;//胃口值
        int lenS = s.length;//尺寸

        Arrays.sort(g);
        Arrays.sort(s);

        int i = lenG - 1, j = lenS - 1;

        int ret = 0;

        while (i >= 0 && j >= 0) {
            if (g[i] <= s[j]) {
                ret++;
                i--;
                j--;
            } else {
                i--;
            }
        }

        return ret;
    }
}
